<!DOCTYPE html>
<html>
<?php $this->load->view('admin/public/header.html');?>
<style>
	. space{padding:10px;}

</style>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space20" lay-filter="expert_form">
	<div class="layui-col-md6 layui-col-xs12 ">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md12 layui-col-xs7">
			
				<div class="layui-form-item magt3 companyImg" style="display:none">
					<div class="layui-row layui-col-space10">
						<div class="layui-col-md6 layui-col-xs6">
							<label class="layui-form-label">公司营业执照</label>
							<div class="layui-upload-list thumbBox posterBox mag0 magt3">
								<img class="layui-upload-img thumbImg posterimg"  src="">
							</div>
						</div>						
					</div>
				</div>
			
				<div class="layui-form-item magt3">
					<label class="layui-form-label">昵称</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="nickName" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">真实姓名</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="realName" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">城市</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="position" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">手机号</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="phone" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="sex" lay-verify="require" disabled >
					</div>
				</div>

				<div class="layui-form-item magt3">
					<label class="layui-form-label">生日</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="birthday" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">身份证号</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="id_number" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">行业</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="trade" lay-verify="require" disabled >
					</div>
				</div>
				
				<div class="layui-form-item magt3">
					<label class="layui-form-label">职业</label>
					<div class="layui-input-block">
						<input type="text" class="layui-input name" name="job" lay-verify="require" disabled>
					</div>
				</div>
				
			</div>
		</div>
		
	</div>
	
</form>
<script type="text/javascript">
var path='/zhuojian/public/appeditor/';
layui.config({
	base : path
}).extend({
	"appeditor" : "appeditor"
})
layui.use(['form','layer','layedit','laydate','upload','appeditor'],function(){
	var el={
			"el" : '#appeditor',
			"name" :  'intro',
			'data' : "[{'text' : 1},{'text' : 3},{'image' : 'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=643873983,4278247275&fm=58'},{'text' : 2}]"
		};	
	
	layui.appeditor._init_(el);
	
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        laypage = layui.laypage,
        upload = layui.upload,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;


    //用于同步编辑器内容到textarea
    layedit.sync(editIndex);

    //上传缩略图
    upload.render({
        elem: '.thumbBox',
        url: '../../json/userface.json',
        method : "get",  //此处是为了演示之用，实际使用中请将此删除，默认用post方式提交
        done: function(res, index, upload){
            var num = parseInt(4*Math.random());  //生成0-4的随机数，随机显示一个头像信息
            $('.thumbImg').attr('src',res.data[num].src);
            $('.thumbBox').css("background","#fff");
        }
    });

    //格式化时间
    function filterTime(val){
        if(val < 10){
            return "0" + val;
        }else{
            return val;
        }
    }
    
    

	form.verify({
        
        
        require : function(val,dom){
        	var name=($(dom).attr('name'));
        	var tips='必填项';
        	switch (name) {
			case 'name':
				tips='专家名称'
				break;
			case 'brief':
				tips='专家简介'
				break;
			case 'position':
				tips='专家所在城市'
				break;
			case 'typeId':
				tips='专家类别'
				break;
			
			default:
				break;
			}
            if(val == ''){
                return tips+"不能为空";
            }
        },
        
        
//        content : function(val){
//            if(val == ''){
//                return "内容不能为空";
//            }
//        }
    })
    
    form.on("submit(addNews)",function(data){
    	
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        
        $.ajax({
        	type:'post',
        	data:data.field,
        	url:'action',
        	dataType: "json", 
        	success:function(res){
        		//console.log(res.code);return;
        		if(res.code==200){
        			top.layer.close(index);
                    top.layer.msg("添加成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
        		}else{
        			top.layer.close(index);
                    top.layer.msg("添加失败！");
        		}
        	},
        	fail:function(){
        		top.layer.close(index);
                top.layer.msg("添加失败！");
        	}
        })        
        
    })

    
    
    //创建一个编辑器
    var editIndex = layedit.build('content',{
        height : 535,
        uploadImage : {
            url : "../../json/newsImg.json"
        }
    });

})
</script>
</body>
</html>